package com.doubao.file.security;

/**
 * 用户上下文，用于存储当前请求的用户ID
 */
public class UserContext {
    private static final ThreadLocal<Long> currentUserId = new ThreadLocal<>();

    public static void setUserId(Long userId) {
        currentUserId.set(userId);
    }

    public static Long getUserId() {
        return currentUserId.get();
    }

    public static boolean isUserLoggedIn() {
        return currentUserId.get() != null;
    }

    public static void clear() {
        currentUserId.remove();
    }
}